// -----------------------------------------------------------------------
// <copyright file="CompositionProfileListEN.cs" company="VDC-IT" author="LTDUC">
//      Copyright (c) VDC-IT. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace VDC.VONE.ENTITIES
{
    using System;
    using System.Collections.Generic;
    using System.Data.SqlClient;
    using Microsoft.ApplicationBlocks.Data;
    using VDC.COMMON;
    
    /// <summary>
    /// Class CompositionProfileList
    /// </summary>
    public class CompositionProfileListEN : EntityEN
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="CompositionProfileListEN" /> class
        /// </summary>
        public CompositionProfileListEN()
        {
            this.CompositionProfileListId = 0;
            this.Code = string.Empty;
            this.Name = string.Empty;
        }

        /// <summary>
        /// Gets or sets CompositionProfileListId
        /// </summary>
        public int CompositionProfileListId { get; set; }

        /// <summary>
        /// Gets or sets Code
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// Gets or sets Name
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Gets ProfileCompositionProfileLists
        /// </summary>
        public IList<ProfileCompositionProfileListEN> ProfileCompositionProfileLists
        {
            get
            {
                try
                {
                    IList<ProfileCompositionProfileListEN> lstProfileCompositionProfileList = new List<ProfileCompositionProfileListEN>();
                    var reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, Constants.StorepProcedure.VOneProfileCompositionProfileListGetByCompositionProfileListId, this.CompositionProfileListId);
                    while (reader.Read())
                    {
                        ProfileCompositionProfileListEN profileCompositionProfileList = new ProfileCompositionProfileListEN();
                        if (!reader.IsDBNull(0))
                        {
                            profileCompositionProfileList.ProfileCompositionProfileListId = reader.GetInt32(0);
                        }

                        if (!reader.IsDBNull(1))
                        {
                            profileCompositionProfileList.ProfileId = reader.GetInt32(1);
                        }

                        if (!reader.IsDBNull(2))
                        {
                            profileCompositionProfileList.CompositionProfileListId = reader.GetInt32(2);
                        }

                        lstProfileCompositionProfileList.Add(profileCompositionProfileList);
                    }

                    reader.Close();
                    reader.Dispose();
                    return lstProfileCompositionProfileList;
                }
                catch (SqlException ex)
                {
                    throw new Exception(ex.ToString());
                }
            }
        }

        /// <summary>
        /// Gets ProfileTypeCompositionProfileLists
        /// </summary>
        public IList<ProfileTypeCompositionProfileListEN> ProfileTypeCompositionProfileLists 
        {
            get
            {
                try
                {
                    IList<ProfileTypeCompositionProfileListEN> lstProfileTypeCompositionProfileList = new List<ProfileTypeCompositionProfileListEN>();
                    var reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, Constants.StorepProcedure.VOneProfileTypeCompositionProfileListGetByCompositionProfileListId, this.CompositionProfileListId);
                    while (reader.Read())
                    {
                        ProfileTypeCompositionProfileListEN profileTypeCompositionProfileList = new ProfileTypeCompositionProfileListEN();
                        if (!reader.IsDBNull(0))
                        {
                            profileTypeCompositionProfileList.ProfileTypeCompositionProfileListId = reader.GetInt32(0);
                        }

                        if (!reader.IsDBNull(1))
                        {
                            profileTypeCompositionProfileList.ProfileTypeId = reader.GetInt32(1);
                        }

                        if (!reader.IsDBNull(2))
                        {
                            profileTypeCompositionProfileList.CompositionProfileListId = reader.GetInt32(2);
                        }

                        lstProfileTypeCompositionProfileList.Add(profileTypeCompositionProfileList);
                    }

                    reader.Close();
                    reader.Dispose();
                    return lstProfileTypeCompositionProfileList;
                }
                catch (SqlException ex)
                {
                    throw new Exception(ex.ToString());
                }
            }
        }
    }
}
